package com.usian.wemedia.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.media.dtos.WmNewsResultDTO;
import com.usian.wemedia.entity.WmNews;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 自媒体图文内容信息表 Mapper 接口
 * </p>
 *
 * @author usian
 * @since 2022-07-08
 */
public interface WmNewsMapper extends BaseMapper<WmNews> {


    /**
     * 分页查询 自媒体文章及其作者信息
     * @param dto
     * @return
     */


    @Select("<script>"+
            "select wn.*,wu.name authorName from wm_news wn inner join wm_user wu on wn.wm_user_id = wu.id "+
            "<where>"+
            "<if test=\"dto.title != null and dto.title != '' \">"+
            "wn.title like concat(concat('%',#{dto.title}),'%')"+
            "</if>"+
            "</where>"+
            "</script>")
    IPage<WmNewsResultDTO> selectWmNewsByPage(Page page,@Param("dto") NewsAuthDto dto);
}
